<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>实验1js实现</title>
</head>
 
<body>
const quickSort = (array) => {
 const sort = (arr, left = 0, right = arr.length - 1) => {
  if (left >= right) {
   return
  }
 let i = left
 let j = right
 const baseVal = arr[j] 
 while (i < j) {
  while (i < j && arr[i] <= baseVal) { 
   i++
  }
  arr[j] = arr[i] 
  while (j > i && arr[j] >= baseVal) { 
   j--
 }
  arr[i] = arr[j] 
 }
 arr[j] = baseVal 
 sort(arr, left, j-1) 
 sort(arr, j+1, right) 
 }
 const newArr = array.concat() 
 sort(newArr)
 return newArr
}
</body>
 
</html>